<?php if(is_array($ctx->getTasks['result']) && count($ctx->getTasks['result'])>0) { ?>
<tal:block tal:repeat="task  getTasks/result">
<?php 
foreach($ctx->task['TaskRelations'] as $relations)
{
?>
<?php 

	$id=$ctx->task['task_id'];
	$type="task_id";
	if($relations['task_status']=="accepted")
	{
	$view_pic="/images/TaskIcon.png";
	$alt="Accepted";
	$title="Accepted";
	}
	else if($relations['task_status']=="reccuring")
	{
	$view_pic="/images/TaskRecurringIcon.png";
	$alt="Reccuring";
	$title="Reccuring";
	}
	else if($relations['task_status']=="overdue")
	{
	$view_pic="/images/TaskOverdueIcon.png";
	$alt="Overdue";
	$title="Overdue";
	}
	else if($relations['task_status']=="completed")
	{
	$view_pic="/images/TaskCompleteIcon.png";
	$alt="Completed";
	$title="Completed";
	}
	else if($relations['task_status']=="isprogress")
	{
		$view_pic="/images/TaskIcon.png";
		$alt="Isprogress";
		$title="Isprogress";
	}
	else if($relations['task_status']=="rejected")
	{
		$view_pic="/images/TaskIcon.png";
		$alt="Rejected";
		$title="Rejected";
	}

if(count($relations['MyFavorites'])>0)
	{
		$user_id = $relations['MyFavorites']['owner_id'];
		$favorite_status = $relations['MyFavorites']['status'];
		
		
	} else {
		$favorite_status = 'Inactive';
		$user_id = '';
	}
?>
<div class="Task">
<?php if($relations['read_status'] == 0) { $class="act";} else { $class="nor"; } ?>
<div class="<?php echo $class;?>">
<div class="blkCont">
<p class="UserImg"><img src="<?php echo $view_pic ?> " alt="<?php echo $alt; ?>" title="<?php echo $title; ?>"  height="40px" width="40px" /></p>
<p class="Date"><?php echo ago(strtotime($ctx->task['added_date']));?></p>
</div>
<div class="blkCont" style="margin-right:0;">
<div class="wid240">
<p class="Title"><a href="/tasks/index/task-view/<?php echo $ctx->type; ?>/<?php echo base64_encode($ctx->getTasks['currentPage']).'/'.base64_encode($relations['id']);?>"><?php echo $ctx->task['task_name'];?></a></p>
<p class="DueDate"><?php echo date($ctx->date_fromat,strtotime($ctx->task['due_date'])); ?></p>
<div>

</div>
</div>
<div>
<?php if(($ctx->type)!=1){ ?>
<span><a id="various2" href="#" class="AssignToLink">Comments (<?php echo $ctx->task['cnt']; ?>)</a></span>
<? } ?>
<!-- Assign to popup  -->

<!-- Assign to popup  -->
<?php if($ctx->task['eventName']!="") { ?>
<span><a href="#" class="CaleLink"><span tal:content="structure php: this.SubStrText(task['eventName'], 25)">Des Here</span></a></span>
<? } ?>
</div>
</div>
<div class="blkContRt">

<?php if($relations['priority'] == 0) { ?>
<span><a href="javascript:void(0);" onclick="changePriorityStatus(<?php echo $relations['id'];?>,'1')"><img src="/images/Emot_4.png" alt="Priority" border="0" class="img_inline" title="Priority" /></a></span>
<?php } else{ ?>
<span><a href="javascript:void(0);" onclick="changePriorityStatus(<?php echo $relations['id'];?>,'0')"><img src="/images/Emot_7.png" alt="Priority" border="0" class="img_inline" title="Priority" /></a></span>
<?php } ?>
<?php if($favorite_status=="Active"&& $user_id==$_SESSION["sess_userid"]){?>
<a href="javascript:void(0);" onclick="changeStatusFavorite(<?php echo $ctx->task['task_id'];?>,'Inactive')"><img src="/images/FavorIconAct.png" alt="Favorite" title="Favorite" /></a>
<? } else {?>
<a href="javascript:void(0);" onclick="changeStatusFavorite(<?php echo $ctx->task['task_id'];?>,'Active')"><img src="/images/FavorIconNor.png" alt="Favorite" title="Favorite" /></a>
<? } ?>
<span><a href="javascript:void(0);" onclick="deleteTask(<?php echo $id;?>,'<?php echo $type;?>');"><img src="/images/CloseIcon.png" alt="Delete" border="0" class="img_inline" title="Delete"/></a></span>
</div>
<div class="clear"></div>
</div>

<div class="clear"></div>
</div>
<? } ?>
</tal:block>
<? } else { ?>
<p style="padding:50px 50px"><b><center>No tasks</center></b></p>
<? } ?>
<script type="text/javascript">
//<![CDATA[
function assignTask(task_id,event_id)
{
	tb_show('Assign to','/tasks/index/assign-task?&task_id='+task_id+'&event_id='+event_id+'&height=400&width=600','');
}
function deleteTask(id,action)
{
	//alert(id+"and"+action);return false;
	$.ajax({
			   
			    type: "POST",
				dataType: "json",
			    data: "val="+id+"&action="+action+"&current_page="+<?php echo $ctx->getTasks['currentPage']; ?>+"&type="+<?php echo $ctx->type ; ?>,
			    url: "/tasks/index/delete-tasks/",
			    success: function(data){
					$('#listAlbums').html(data.output);
									
				}
			});
}
function changeStatusFavorite(task_id,status)
{
	//alert(task_id+"and"+status);return false;
	$.ajax({
			   
			    type: "POST",
				dataType: "json",
			    data: "task_id="+task_id+"&status="+status+"&module_type=tasks&current_page="+<?php echo $ctx->getTasks['currentPage']; ?>+"&type="+<?php echo $ctx->type ; ?>,
			    url: "/tasks/index/favorites/",
			    success: function(data){
					$('#listAlbums').html(data.output);					
				}
			});
}
function changePriorityStatus(realtion_id,status)
{
	//alert(trigger_id+"and"+status);return false;
	$.ajax({
			   
			    type: "POST",
				dataType: "json",
			    data: "realtion_id="+realtion_id+"&status="+status+"&module_type=tasks&current_page="+<?php echo $ctx->getTasks['currentPage']; ?>+"&type="+<?php echo $ctx->type ; ?>,
			    url: "/tasks/index/change-priority-status/",
			    success: function(data){
					$('#listAlbums').html(data.output);					
				}
			});
}


//]]>
</script>
